const proxy = require("http-proxy-middleware");
module.exports = function (app) {
  app.use(
    proxy('/api1', {//遇见/api1前缀的请求，就会触发该代理配置
      target: "http://localhost:5000",
      //changeOrigin: false,// host: 'localhost:3000'  不改变源服务器端接收到的host为3000
      changeOrigin: true,// host: 'localhost:5000'  改变源服务器端接收到的host为5000（推荐）
      pathRewrite: { "^/api1": "" }//重写请求路径  
    }),
    proxy('/api2', {
      target: "http://localhost:6000",
      changeOrigin: true,
      pathRewrite: { "^/api2": "" }
    })
  )
}